﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;

namespace TechControl.BD
{
    class UserDB: BaseDB
    {
        private static UserDB instance;

        private UserDB() { }

        public static UserDB getInstance()
        {
            if (instance == null)
            {
                instance = new UserDB();
            }
            return instance;
        }
        //retorna se o usuário existe ou não.
        public bool checkLogin(string user, string senha)
        {
            try
            {
                this.open();
                SqlCommand command = new SqlCommand("SELECT * FROM TB_USER WHERE LOGIN=@user and SENHA=@senha;", this.conn);
                command.Parameters.AddWithValue("@user", user);
                command.Parameters.AddWithValue("@senha", senha);
                SqlDataReader rdr = command.ExecuteReader();
                bool result = false;

                while (rdr.Read())
                {
                    result = true;
                }

                return result;
            }
            finally
            {
                this.close();
            }
        }
    }
}
